$(function(){
    //节流阀
    var flag = false;
    function loadClassifyData() {
        if(flag) return false;
        $.ajax({
            type: "get",
            // url: domain.test + "/getcategory",
            url: domain.online + "/api/category",
            dataType: "json",
            beforeSend: function () {
                flag = true;
            },
            success: function (response) {
                // if(response.data.rtnCode===200) {
                if(response.rtnCode===200) {
                    // var classifyDetail = response.data.data;
                    var classifyDetail = response.data;
                    $(".contentBox").html(template("contentBox",{classifyDetail:classifyDetail}));
                    pullmaster.pullDownSuccess();
                    flag = false;
                }
            }
        });
    }
    loadClassifyData();
    var pullmaster = new Pull($('.contentBox'), {
        onPullDown: function () {
            loadClassifyData();
        }
    });
    //分类跳转
    $(".contentBox").on("click",".classifyItem",function(){
        var clsId = $(this).attr("data-id");
        var picUrl = $(this).attr("picUrl");
        var title = $(this).attr("data-title");
        location.href = "./classifyProduct.html?clsId=" + clsId + "&picUrl=" + picUrl + "&title=" + title;
    });
    //跳转到搜索页
    $(".searchIcon").on("click",function(){
        location.href = "../search/search.html";
    })
});